package org.example.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.example.service.FeignService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author TonySong
 * @date 2024/5/6 0006
 * @time 9:37
 */
@RestController
@Slf4j
public class CoumserController {

    @Value("${server.port}")
    private Integer port;

    @Resource
    private FeignService feignService;

    @GetMapping("/buy/{id}")
    public String pay(@PathVariable("id") Integer id){
        return this.port + ":" + feignService.order(id);
    }

    @GetMapping("/test1")
    public String test1(HttpServletRequest request){
         log.info("请求头："+ request.getHeader("good"));
         return "test1";
    }

    @GetMapping("/test2")
    public String test2(@RequestHeader("good") String color){
         log.info("请求头："+ color);
         return "test2";
    }

    @GetMapping("/test3")
    public String test3(@RequestParam("color") String color){
         log.info("请求头："+ color);
         return "test3";
    }

    @GetMapping("/test4")
    public String test4(){
         log.info("重定向");
         return "test4";
    }
}
